home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 7 / Eagles_Nest_Mac_Collection_Disc_7.TOAST / General Communication / WBPEP-ARA < prev    next >
Text File  |  1992-07-06  |  26KB  |  737 lines

  1. Article 11867 of comp.sys.mac.comm:
  2. Xref: caen comp.sys.mac.comm:11867 comp.dcom.modems:21222
  3. Path: caen!uakari.primate.wisc.edu!ames!apple!apple!sphns
  4. From: kateley@apple.com (Jim Kateley)
  5. Newsgroups: apple.remote-access,comp.sys.mac.comm,comp.dcom.modems
  6. Subject: ARA script for Telebit WorldBlazer (Turbo-PEP)
  7. Message-ID: <kateley-200692210839@sphns.support.apple.com.>
  8. Date: 21 Jun 92 04:11:24 GMT
  9. Sender: daemon@Apple.COM
  10. Followup-To: apple.remote-access
  11. Distribution: usa
  12. Organization: Apple Computer Campbell
  13. Lines: 720
  14.  
  15. Hello there,
  16.  
  17. Here is an AppleTalk Remote Access script for the Telebit WorldBlazer using
  18. Turbo-PEP as it's maximum speed.  There was a previous posting using
  19. V.32bis as the WorldBlazer's maximum speed that most people will probably
  20. want to use instead of this script.  Please read the script comments for
  21. the implications of using this script.  In particular, read the comments
  22. above LABEL 5.
  23.  
  24. ____________________________cut here_____________________________
  25. ! "Telebit WorldBlazer Modem (Turbo-PEP) 6/4/92" JFK
  26. ! Adapted from the Telebit T3000 script
  27. ! "Telebit T3000 Modem 11/11/91" JFK
  28. ! 11/14/91 JFK - Added a ton o' comments...
  29. ! 11/23/91 JFK - Cleaned up comments a little bit more,
  30. !                and added S11=50.
  31. ! 12/2/91  JFK - Took S11 back out.
  32. ! 12/9/91  JFK - Added the pinouts for the RTS/CTS cable to the comments
  33. !                Since you have to make a hardware handshaking cable.
  34. ! 1/16/92  JFK - Add a bunch more comments about the cable.
  35. ! 3/30/92  JFK - Added comments about the hang up sequence.
  36. ! 3/31/92  JFK - Added sbreak in hangup sequence to speed things up.
  37. ! 3/31/92  JFK - Added S38=3 to help ensure that the modem will be
  38. !                able to transmit all the data in its buffer (including
  39. !                the disconnect command for the remote modem!) before
  40. !                it hangs up.
  41. ! 4/2/92   JFK - Changed S38 to 255.  See notes below.
  42. ! 4/2/92   JFK - Changed S51 to 254 in hang up sequence since 19200 is
  43. !                the DTE speed.
  44. ! 6/4/92   JFK - I actually forgot to set S51 to 254 on 4/2.  It's done
  45. !                now
  46. ! 6/4/92   JFK - Added Short break and 1/2 second pause in label
  47. !                64.  Apparently the WorldBlazer's command mode
  48. !                is not as robust as the T3000, so this step
  49. !                is done to ensure the modem will respond to commands
  50. !                after it is hung up.  If it is not, the script will
  51. !                not be able to configure the modem to answer the
  52. telephone.
  53. !                Also, if label 64 does not receive an "OK", loop back
  54. !                up to the top of the hangup sequence (label 60) and try
  55. again.
  56. ! 6/12/92  JFK - Began to test Turbo PEP stuff.
  57. ! 6/13/92  JFK - Set S51 to 253 in hang up sequence since 38400 is
  58. !                the DTE speed.
  59. ! 6/13/92  JFK - Cleaned up comments.  Set DTE speed to 38400 since
  60. !                Turbo-PEP should be able to communicate at 23000 bps.
  61. !                NOTE:  This script may have problems with
  62. !                other vendors V.32/V.32bis modems.  When the WorldBlazer
  63. !                answers the telephone, either as a server being dialed
  64. !                into, or as a client during a callback, it will issue
  65. !                Turbo-PEP tones before V.32bis/V.32/V.22bis/etc.  Some
  66. !                other modems will attempt to respond to the Turbo-PEP
  67. tones,
  68. !                with the result being they drop down to V.22bis tones
  69. !                before the WorldBlazer issues V.32bis/V.32 tones.  The
  70. !                end result is the modems connect at 2400 baud even though
  71. !                they may be capable of communicating at 9600 or 14,400
  72. bps.
  73. !                If this is the case, use the Telebit WorldBlazer (V.32bis)
  74. !                script instead of this one.  It does not attempt to use
  75. !                Turbo-PEP.
  76. !
  77. !  Note the cable requirements when using a V.32bis modem.  Since a lot
  78. !  of people do not have this cable, you should not use this approach when
  79. !  scripting for V.32 or slower modems.
  80. !
  81. ! Cable needed to use AppleTalk Remote Access with V.32bis modems:
  82. !   Din-8    DB-25
  83. ! 1 (DTR)   4,20 (RTS, DTR)
  84. ! 2 (CTS)   5 (CTS) *
  85. ! 3 (TxD-)  2 (TD)
  86. ! 4 (SG)    7 (SG)
  87. ! 5 (RxD-)  3 (RD)
  88. ! 6 (TxD+)  Not Connected
  89. ! 7 (GPi)   8 (DCD)
  90. ! 8 (RxD+)  7 (SG)
  91. !  
  92. ! * Normally 2(CTS)<->6 (DSR) on other Macintosh cables.
  93. !
  94. !-  One consequence of using this cable is that DSR (or DCD) from the modem
  95. is  
  96. !   no longer connected to the Macintosh.  This does not let your Macintosh
  97.  
  98. !   communication software use the DSR (or DCD) signal to detect carrier
  99. loss.  
  100. !   And since the Macintosh Serial driver does not support the GPi
  101. input...you 
  102. !   are sort of stuck, unless your communications software does use the GPi
  103.  
  104. !   input.  Or Apple builds GPi support into the serial driver.
  105. !
  106. !-  Since DTR and RTS are connected together, the modem must be configured
  107. !   to ignore DTR (usually the &D0 command) when using this cable with
  108. other 
  109. !   communications applications.  Otherwise, when RTS handshaking from the
  110. Mac 
  111. !   is used, the modem will drop connection the first time the Mac
  112. de-asserts 
  113. !   RTS.
  114. !
  115. !-  If there is a need to use DTR to make the modem disconnect, RTS
  116. handshaking 
  117. !   cannot be used to control the flow of data from the modem to the
  118. Macintosh.  
  119. !   CTS handshaking (from the modem to the Macintosh) is available.  This
  120. is 
  121. !   what ARA does so it can force the modem to hang up, and at the same
  122. time 
  123. !   the modem can signal the Macintosh to stop sending data.  This assumes
  124. that 
  125. !   the Macintosh will always be able to accept data from the modem.  This
  126. will 
  127. !   not be true if the Macintosh is talking to the modem at 57.6KBps with 
  128. !   V.32bis & V.42Bis.  There will be times when the Macintosh will need to
  129.  
  130. !   signal the modem to stop sending data.
  131. !
  132. !In summary, with this cable:
  133. !
  134. !If you want to use RTS hardware handshaking, you cannot use DTR to control
  135. the 
  136. !modem.  You will have to resort to other methods to coerce the modem to 
  137. !disconnect.
  138. !
  139. !If you want to control the modem with DTR, you cannot use RTS hardware 
  140. !handshaking so the Macintosh must be able to accept data from the modem at
  141. all 
  142. !times, or can recover if data is lost.
  143. !
  144. !In either case you can use CTS hardware handshaking so the modem can
  145. signal 
  146. !the Macintosh to discontinue sending data.
  147. !
  148. @ORIGINATE
  149. @ANSWER
  150. !
  151. ! Talk to the modem at 38,400 bps.  the WorldBlazer should auto-baud this
  152. ! unless the user has locked the port to a particular speed.  If it
  153. ! is locked to a different speed, the user will need to change that.
  154. !
  155. serreset 19200, 0, 8, 1
  156. setspeed 38400
  157. !
  158. !  The idea here is to get the modem into a known state, and then change
  159. only 
  160. !  the registers that are necessary to support the connection.  Most of the
  161.  
  162. !  time AT&F will be sufficient, but some modems allow the user to change
  163. the 
  164. !  F0 parameters.  There isn't much that can be done to prevent this, but
  165. if 
  166. !  the modem has any pre-configured configurations, and one of them sets 
  167. !  hardware handshaking, use it.
  168. !
  169. ! Recall the factory configuration
  170. ! F9 is the built in pre-configured setting for CTS/RTS handshaking on the 
  171. ! WorldBlazer.  Since it's possible for the user to modify F0 parameters,
  172. this 
  173. ! is a little safer.
  174. !
  175. ! AT&F9 sets:
  176. ! &C1 - DCD is on after connect
  177. ! &D2 - DTR on/off disconnects
  178. ! S58=2 - Use RTS/CTS flow control in full-duplex mode
  179. ! S61=1 - Go into command mode when receiving break from DTE (see
  180. !         @HANGUP for why the script cares about this).
  181. ! S181=1 - Turn *on* DTE <-> line buffering if there is no error control.
  182. !                            Since the modem will be talking to the Mac at 
  183. !                            38,400 bps no matter what speed it connects
  184. at, 
  185. !                            this needs to be on.
  186. !
  187. !  Every time the script needs to send commands to the modem, the strategy
  188. is:  
  189. !  Clear all matchstrings, look for specific responses, and loop around a 
  190. !  couple of times.  Later in the script, certain loops pause 50-70
  191. seconds, 
  192. !  such as when the script dials a number and is waiting for a connection. 
  193.  
  194. !  Other times, the script pauses 3-5 seconds and loops around. When the
  195. script 
  196. !  is sending commands to the modem, it should expect to see a response
  197. within 
  198. !  a couple of seconds, so it's best to look quickly and exit with an error
  199. in 
  200. !  a reasonable amount of time so the user does not wait a for a long time 
  201. !  before they are notified that they may need to power-cycle/reset the
  202. modem.  
  203. !  When the script is dialing out over a telephone system or PBX, it needs 
  204. !  enough time to make a connection.  In short, if it's communicating to a 
  205. !  modem, loop in 3-7 second increments.  If the script is waiting for 
  206. !  something other than a modem response (like a completed connection or 
  207. !  terminal server) it may need 60-70 seconds.
  208. !
  209. !  If the defaults cannot be set, jump down to label 59, which exits and
  210. asks 
  211. !  the user to check out the modem.  If an  AT&F command will not be
  212. accepted, 
  213. !  the modem may be hung and needs to be manually reset.
  214. !
  215. settries 0
  216. matchclr
  217. @LABEL 1
  218. matchstr 1 4 "OK\13\10"
  219. write "AT&F9\13"
  220. matchread 30
  221. inctries
  222. iftries 2 59
  223. ! Modem is not responding, reset and send a break
  224. DTRClear
  225. pause 5
  226. DTRSet
  227. SBreak
  228. jump 1
  229. !
  230. !  The script was able to get the modem into a default factory state.  Now 
  231. !  set the basic hardware type configuration such as command echo, hardware
  232.  
  233. !  handshaking, and DTR control.  If the &F9 command had not set up
  234. handshaking 
  235. !  this is where it would be done.  It's not desirable to create one long 
  236. !  command string with everything on it because some modems cannot handle a
  237.  
  238. !  long command string, and long strings are harder to debug.  It's easy
  239. !  to enter an incorrect S-register value.  For the most part, the
  240. following 
  241. !  commands are probably common across a lot of modems, but always look up
  242. the 
  243. !  commands in the modem manual.
  244. !
  245. ! Next, Set up the configuration: drop connection after losing DTR
  246. !    Turn off auto answer and command echo.   
  247. !
  248. ! &D3 - DTR on/off resets modem 
  249. ! S0=0 - Don't answer calls
  250. ! E0 - Turn command echo off
  251. @LABEL 4
  252. matchclr
  253. pause 5
  254. matchstr 1 5 "OK\13\10"
  255. write "AT&D3S0=0E0\13"
  256. matchread 30
  257. jump 59
  258. !
  259. !  Now that the modem hardware & flow control parameters are set, make sure
  260. any 
  261. !  protocol negotiation is disabled, and issue any modem specific features 
  262. !  here.  Make sure that MNP4/V.42, and MNP5-10/V.42bis negotiations are 
  263. !  disabled.  By the way, some V.32/V.32bis modems have an option to
  264. disable 
  265. !  Trellis error control,  which is part of the physical layer modulation. 
  266.  
  267. !  This is not the same as MNP/V.42, and you do not want to disable it!
  268. !
  269. !  Make sure that the modem is configured so it does NOT require error
  270. control 
  271. !  to complete a link.  ARA 1.0 does all error correction/data compression
  272. in 
  273. !  software.  All ARA wants is the fastest raw data pipe it can get.  If
  274. the 
  275. !  script spends time trying to negotiate some error control, the modems
  276. and/or 
  277. !  Remote Access may time out.
  278. !
  279. !  Also note the S38 configuration.  It is noted later in the script that
  280. it is 
  281. !  desirable to ensure that the modem's buffer has transmitted all of it's
  282. data 
  283. !  before it actually hangs the modem up.  This ability appears to be 
  284. !  implemented on a lot of modems.
  285. !
  286. !  This set of commands is going to be implemented differently on different
  287. !  vendors V.32bis modems.  In this example, Telebit uses S registers.
  288. !  Other modems may use S registers (but different registers), or \
  289. !  commands, or % commands; you get the idea.  (Did I mention that you
  290. !  really, really want to have your modem manual handy?)
  291. !
  292. !  It is important that the modem is configured so that it returns
  293. !  the connected speed, NOT the DTE speed.  The script need to know what
  294. the 
  295. !  real line speed is in order to set ARA's internal timers.  Some
  296. !  modems don't have the option to display the line speed.  In that case
  297. the 
  298. !  performance of the connection may not be optimal.
  299. !
  300. ! Next, disable MNP and error control, set the delay before disconnect,
  301. ! and extended result codes (CTS/RTS flow control and internal DTE<->DCE
  302. ! buffering was set when &F9 was issued , so it is not necessary to do it 
  303. ! again).
  304. !
  305. ! Note that the modulation speed (S50) defaults to 0 with &F9, which
  306. ! means the modem will attempt to connect at the fastest possible
  307. ! speed, including Turbo-PEP.  To date (6/13/92) Turbo-PEP is not effective
  308. ! for ARA, as it's half-duplex behavior is not optimal for ARA's buffering
  309. ! and AppleTalk's acknowledgement timers.  AFP (AppleShare), ATP (MS-Mail),
  310. ! and some ADSP applications (Apple's X.25 server in particular) function
  311. ! poorly under Turbo-PEP.
  312. !
  313. ! This script is provided so that the user will be able to create a
  314. connection
  315. ! where V.32bis will not function (i.e. international connections, older
  316. ! telephone systems).  However, it is unclear if the resulting connection
  317. has 
  318. ! any value.  Be aware that the author of this script is keenly interested
  319. ! in increasing ARA's performance and robustness.  If any improvements in
  320. ! either Turbo-PEP (full duplex, tune-able backchannels) or ARA (tuning for
  321. ! half-duplex links) emerge, a script capable of taking advantage of any
  322. such
  323. ! enhancements would be quickly written and issued.
  324. !
  325. ! S180=0 - Turn off all error detection/correction (ARA does MNP and
  326. !          compression itself.  It needs these turned off in the modem).
  327. ! S38=255  - Wait until the modem's buffer is clear OR the other modem 
  328. !            disconnects after an ATH is issued before dropping the line.
  329. !            This is done to ensure that all any data in the modem's buffer
  330. !            has been transmitted to the remote modem before it
  331. disconnects.
  332. !            If the remote connection does not receive the
  333. !            disconnect packet (usually the last one sent) it could take
  334. !            up to 45 seconds for the remote connection to timeout and
  335. !            disconnect.
  336. ! X2 - Issue extended result codes.  This will display busy, connect XXX,
  337. etc.
  338. !      X2 will say "CONNECT XXX"  Where XXX is the line speed (as opposed
  339. to
  340. !      DTE speed).  This is so ARA can determine what speed the modems are 
  341. !      communicating at for timing.
  342. !
  343. @LABEL 5
  344. pause 5
  345. matchstr 1 6 "OK\13\10"
  346. write "ATS180=0S38=255X2\13"
  347. matchread 30
  348. jump 59
  349. !
  350. !  The modem should now be properly configured.  Now check to see if the
  351. user 
  352. !  has turned off the modem speaker.  If they have, send an additional
  353. command 
  354. !  to turn it off.
  355. !
  356. ! If speaker on flag is true, jump to label 8.  Otherwise turn off the
  357. speaker.
  358. !
  359. @LABEL 6
  360. ifstr 2 8 "1"
  361. pause 5
  362. matchstr 1 8 "OK\13\10"
  363. write "ATM0\13"
  364. matchread 30
  365. jump 59
  366. !
  367. ! The modem is ready so enable answering, or originate a call.
  368. !
  369. @LABEL 8
  370. pause 5
  371. ifANSWER 30
  372. note "Dialing ^1" 3
  373. write "ATDT^1\13"
  374. !
  375. !  Be aware that different modems will have different format strings 
  376. !  to return connection results.  You need to understand the different
  377. possible 
  378. !  strings and set this area (and then answer area at label 31) to the 
  379. !  appropriate value.  Also, remember that the modem was configured to
  380. return 
  381. !  the connect speed if possible (The X2 command up at label 5).  It's also
  382.  
  383. !  useful if the modem can return busy, no dialtone, etc. since the script
  384. will 
  385. !  be able to exit quicker and let the user know what is going on.
  386. !
  387. !  Also note that the script waits at the bottom of label 9 for a 70
  388. seconds, 
  389. !  rather then looping around.  Why?  Well, if the script re-issues the
  390. dial 
  391. !  command too soon, that would cause the modem to hang up.  At this point
  392. the 
  393. !  script should wait a reasonable amount of time for one of these strings
  394. to 
  395. !  return from the modem and take the appropriate action.
  396. !
  397. @LABEL 9
  398. matchstr 1  11 "CONNECT 1200\13\10"
  399. matchstr 2  12 "CONNECT 2400\13\10"
  400. matchstr 3  13 "CONNECT 4800\13\10"
  401. matchstr 4  19 "CONNECT 7200\13\10"
  402. matchstr 5  14 "CONNECT 9600\13\10"
  403. matchstr 6  20 "CONNECT 12000\13\10"
  404. matchstr 7  18 "CONNECT 14400\13\10"
  405. matchstr 8  50 "NO CARRIER\13\10"
  406. matchstr 9  50 "ERROR\13\10"
  407. matchstr 10 52 "NO DIALTONE\13\10"
  408. matchstr 11 53 "BUSY\13\10"
  409. matchstr 12 54 "NO ANSWER\13\10"
  410. matchstr 13 21 "CONNECT FAST\13\10"
  411. matchread 700
  412. jump 59
  413. !
  414. !  All that is done for different connect speeds is to issue a 
  415. !  "CommunicatingAt" command.  Remember, the interface speed is locked
  416. !  to 38,400 bps so the script doesn't want to reset the serial speed after
  417. it 
  418. !  connects.
  419. !
  420. !  CommunicatingAt tells ARA what the actual line speed is so that it
  421. !  can set it's timers appropriately.  I guess performance would be
  422. !  sub-optimal if this is not set...
  423. !
  424. @LABEL 11
  425. note "Communicating at 1200 bps." 2
  426. CommunicatingAt 1200
  427. jump 15
  428. !
  429. @LABEL 12
  430. note "Communicating at 2400 bps." 2
  431. CommunicatingAt 2400
  432. jump 15
  433. !
  434. @LABEL 13
  435. note "Communicating at 4800 bps." 2
  436. CommunicatingAt 4800
  437. jump 15
  438. !
  439. @LABEL 19
  440. note "Communicating at 7200 bps." 2
  441. CommunicatingAt 7200
  442. jump 15
  443. !
  444. @LABEL 14
  445. note "Communicating at 9600 bps." 2
  446. CommunicatingAt 9600
  447. jump 15
  448. !
  449. @LABEL 20
  450. note "Communicating at 12000 bps." 2
  451. CommunicatingAt 12000
  452. jump 15
  453. !
  454. @LABEL 18
  455. note "Communicating at 14400 bps." 2
  456. CommunicatingAt 14400
  457. jump 15
  458. !
  459. @LABEL 21
  460. note "Communicating with Turbo-PEP." 2
  461. !
  462. ! CommunicatingAt is set to 110 here instead of 19200 in the hopes that 
  463. ! setting ARA's timers to a longer value with help performance with
  464. ! Turbo-PEP.  It doesn't seem to (6/13/92).
  465. !
  466. CommunicatingAt 110
  467. jump 15
  468. !
  469. ! Set CTS handshaking ON in the serial port (that's the 1 in the HSReset
  470. ! command below )
  471. !
  472. !  The modems have connected, so enable hardware handshaking on the serial 
  473. !  port.  If the script is answering a telephone call, just exit right away
  474. and 
  475. !  starting communicating.  If the script is dialing out, give the other
  476. end 
  477. !  some time (3 seconds in this example) to get ready to talk to this
  478. modem.
  479. !  Exit 0 tells Remote Access that the script was successful in attempting
  480. a
  481. !  connection.
  482. !
  483. @LABEL 15
  484. HSReset 0 1 0 0 0 0 
  485. ifANSWER 16
  486. pause 30
  487. @LABEL 16
  488. exit 0
  489. !
  490. !  Notice that the @ANSWER label is actually a comment here, and that 
  491. !  @ORIGINATE and @ANSWER start at the same place.  What's the point of
  492. having 
  493. !  separate entry points if they are not used?  Well, in the case of
  494. modems, 
  495. !  when they dial out or wait for a call, the setup is usually the same. 
  496. One 
  497. !  reason for separate entry points is when the script is not directly
  498. talking 
  499. !  to a modem, but maybe to a PBX or terminal server.  It may be necessary
  500. to 
  501. !  have completely different configuration for answering and originating 
  502. !  connections.
  503. !
  504. ! @ANSWER
  505. ! Set up the modem to answer the telephone.
  506. !
  507. @LABEL 30
  508. write "ATS0=1\13"
  509. matchstr 1 31 "OK\13\10"
  510. matchread 30
  511. jump 59
  512. !
  513. !  What is userhook 1 doing in label 32?  Here's the idea:  Either this
  514. script 
  515. !  controls a server that is waiting to answer the telephone, or it's
  516. waiting 
  517. !  for a callback to a connection that was initiated.  AppleTalk Remote
  518. Access 
  519. !  does a "passive" listen on the serial port (via the Serial Port
  520. Arbitrator) 
  521. !  so that other communications applications can use the serial port when
  522. ARA 
  523. !  is not using it.  When a call comes in for a server or callback, there
  524. !  will be about 5-14 seconds while the modems negotiate the connection.
  525. !  What would happen if a communications application on this Macintosh 
  526. !  wanted to use the serial port during that time?  Both connections
  527. !  would fail.  The userhook 1 command tells ARA to mark the serial port in
  528.  
  529. !  use.  When that happens, applications that want to use the serial port
  530. will 
  531. !  be told it's busy, and the incoming connection can complete.  With that
  532. in 
  533. !  mind, the strategy below is:  When the modem receives a ring, jump to
  534. label 
  535. !  32, issue the userhook 1 command, then jump back up to label 31, wait
  536. for 
  537. !  the connect result code and continue processing the script.
  538. !
  539. @LABEL 31
  540. matchstr 1  32 "RING\13\10"
  541. matchstr 2  11 "CONNECT 1200\13\10"
  542. matchstr 3  12 "CONNECT 2400\13\10"
  543. matchstr 4  13 "CONNECT 4800\13\10"
  544. matchstr 5  19 "CONNECT 7200\13\10"
  545. matchstr 6  14 "CONNECT 9600\13\10"
  546. matchstr 7  20 "CONNECT 12000\13\10"
  547. matchstr 8  18 "CONNECT 14400\13\10"
  548. matchstr 9  50 "NO CARRIER\13\10"
  549. matchstr 10 50 "ERROR\13\10"
  550. matchstr 11 52 "NO DIALTONE\13\10"
  551. matchstr 12 53 "BUSY\13\10"
  552. matchstr 13 54 "NO ANSWER\13\10"
  553. matchstr 13 21 "CONNECT FAST\13\10"
  554. matchread 700
  555. jump 31
  556. !
  557. @LABEL 32
  558. userhook 1
  559. note "Answering phone..." 2
  560. jump 31
  561. !
  562. !  These are some common error messages when the line is busy, no dialtone,
  563.  
  564. !  etc. They are documented in the Scripting Language Guide.  When the
  565. script 
  566. !  exits with a code other than zero, Remote Access knows that the
  567. connection 
  568. !  failed, and will inform the user with a dialog.
  569. !
  570. ! 50: error messages
  571. !
  572. @LABEL 50
  573. exit -6021
  574. !
  575. @LABEL 52
  576. exit -6020
  577. !
  578. @LABEL 53
  579. exit -6022
  580. !
  581. @LABEL 54
  582. exit -6023
  583. !
  584. @LABEL 59
  585. exit -6019
  586. !
  587. ! Hang up the modem
  588. ! Note:  Why try to enter command mode and hang up the line with ATH, when 
  589. !        de-asserting DTR will always work, and it is used as a last resort
  590.  
  591. !        anyway?  If DTR is used immediately,  the modem will hang up 
  592. !        immediately.  This can have the ill effect of hanging up before
  593. all 
  594. !        the data in the modem's internal transmit buffer has been sent.
  595. !        It is very desirable to have the last byte of data sent make
  596. !        it out of the modem and across the phone line.  Typically,
  597. !        the last packet sent is the disconnect packet, and if
  598. !        the other side misses this packet, it may have to wait up to 45 
  599. !        seconds to hang up.
  600. !
  601. @HANGUP
  602. @LABEL 60
  603. settries 0
  604. HSReset 0 0 0 0 0 0 
  605. @LABEL 61
  606. !
  607. !  Here's the basic logic for hanging up: If the modem can be configured
  608. !  to enter command mode when it receives a short break, send a short
  609. !  break.  Send an ATH to hang the line up (and if possible up in the 
  610. !  configuration, set the modem to attempt to send all the data in the 
  611. !  buffer before it disconnects).  If that fails, it must still be on
  612. !  line, so send the escape sequence to try to drop into command mode.
  613. !  Don't issue a short break again since it did not work the first time.
  614. !  If that fails, de-assert DTR which should force the modem to hang up
  615. !  (make sure the cable is wired properly for this option!).
  616. !  If +++ worked, don't send a short break again; flush the serial port 
  617. !  buffer in case the ATH failed due to any stray data hanging around.
  618. !
  619. !  How was this sequence determined?  Trial and error.  Different vendor's 
  620. !  modems behave differently when disconnecting.  Some modems will not
  621. enter 
  622. !  command modem during a disconnect, and the only option is to de-assert
  623. DTR 
  624. !  to force them to reset.  That's why DTR resets the modem instead of just
  625. !  disconnecting it!  Experiment with this sequence to make it function,
  626. but it 
  627. !  should work with the majority of the modems available.
  628. !
  629. ! Now, since the Telebit modems will drop into command mode when they
  630. receive
  631. ! a short break (S61=1), issue one here.  This will speed up the disconnect
  632. ! sequence by about 5-6 seconds.  Then continue on with normal AT
  633. disconnect
  634. ! processing.
  635. !
  636. Sbreak
  637. !
  638. ! Wait a brief amount of time (1/2 second in this case) so the modem will
  639. be 
  640. ! ready to accept the ATH command.  Pause 1 actually seems to work ok, but 
  641. ! it's set to 5 just to be safe.
  642. !
  643. pause 5
  644. write "ATH\13"
  645. matchclr
  646. matchstr 1 63 "NO CARRIER\13\10"
  647. matchstr 2 63 "OK\13\10"
  648. matchstr 3 63 "ERROR\13\10"
  649. matchread 30
  650. inctries
  651. iftries 3 63
  652. !
  653. ! No response, try escape sequence.  The WorldBlazer does not use
  654. ! the Hayes patented escape sequence with guard time.  It uses the
  655. ! +++AT<command> method now being adopted by most modem manufacturers.
  656. ! Since that is the case, issue +++AT here to attempt to get the modem
  657. ! into command state.
  658. !
  659. write "+++AT\13"
  660. matchclr
  661. matchstr 1 62 "OK\13\10"
  662. matchread 15
  663. !
  664. ! No Response from modem, toggle DTR
  665. !
  666. DTRClear
  667. pause 5
  668. DTRSet
  669. jump 61
  670. !
  671. @LABEL 62
  672. ! Pause 1 second to ensure we meet the escape time delay
  673. pause 10
  674. Flush
  675. write "ATH\13"
  676. matchstr 1 63 "OK\13\10"
  677. matchstr 2 63 "NO CARRIER\13\10"
  678. matchstr 3 63 "ERROR\13\10"
  679. matchread 30
  680. jump 61
  681. !
  682. !  Now that the modems have disconnected, and the script has possibly reset
  683. the 
  684. !  modem, restore the factory settings.  Remember, the script may have hung
  685. up 
  686. !  the modem in order to get ready for a callback, or it wants to get ready
  687. to 
  688. !  wait to answer a call again.
  689. !
  690. ! recall the factory settings.  Use &F9 again (see note at top of script)
  691. !
  692. @LABEL 63
  693. matchclr
  694. matchstr 1 64 "OK\13\10"
  695. pause 15
  696. write "AT&F9\13"
  697. matchread 30
  698. !
  699. !  Now turn off auto answer if it was turned on to answer a call.  If this 
  700. !  script controls a server, the @ANSWER sequence will be called by ARA.
  701. !  One other thing to watch out for here is that some modems expect to
  702. !  talk to the DTE at the last connected speed.  If this is a V.32bis 
  703. !  modem and it just finished a connection with a 2400 baud modem, it
  704. !  doesn't necessarily want to talk at 2400 the next time!  Some modems
  705. !  don't exhibit this behavior, so play with it and see what happens. 
  706. Finally, 
  707. !  since it successfully hung up,  exit the script with a result code of 0
  708. to 
  709. !  let Remote Access know everything worked.
  710. !
  711. ! Turn off auto answer, set S51 so modem will check interface
  712. ! speed on next connection.  If this is not done, the modem
  713. ! will not try to autobaud, with the result being it exits the 
  714. ! script with an error.
  715. ! S51=253 - Autobaud (38400 bps default)
  716. ! S0=0 - Don't try to answer the phone
  717. !
  718. @LABEL 64
  719. Sbreak
  720. pause 5
  721. matchstr 1 65 "OK\13\10"
  722. write "ATS51=253S0=0\13"
  723. matchread 20
  724. jump 60
  725. !
  726. @LABEL 65
  727. exit 0
  728. _____________________________end________________________________
  729.  
  730. Jim Kateley
  731. Apple Computer Inc.
  732. Disclaimer:  This is me talking.
  733.  
  734.  
  735.